#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：python常用模块库 
@File ：tmp_sender.py
@IDE  ：PyCharm 
@Author ：李涵彬
@Date ：2025/2/20 上午12:22 
"""
import time

from protocols.tcp_protocol import TCPProtocol
from protocols.udp_protocol import UDPProtocol


def send(protocol: str, host: str, port: int, data: bytes):
	if protocol == 'tcp':
		sender = TCPProtocol(host, port)
		sender.send(data)
		sender.stop()
	elif protocol == 'udp':
		sender = UDPProtocol(host, port)
		sender.send(data)
		sender.stop()


if __name__ == '__main__':
	for i in range(10):
		send('udp', '127.0.0.1', 8080, b'Hello World!')
		time.sleep(1)
